package com.fenghongzhang.lib_xmpp.impl;

import android.util.Log;

import com.fenghongzhang.lib_xmpp.XmppManager;
import com.fenghongzhang.lib_xmpp.contract.IXmppUser;

import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.XMPPException;

import java.io.IOException;

public class DefaultXmppUserImpl implements IXmppUser {
    @Override
    public boolean login(String userName, String passWord) {
        try {
            if (!XmppManager.getInstance().getConnection().isAuthenticated()) { // 判断是否登录
                XmppManager.getInstance().getConnection().login(userName, passWord);
                Log.d("123", "login: -----------");
                return true;
            }
            Log.d("123", "login: .........");
            return false;
        } catch (XMPPException | SmackException | InterruptedException | IOException e) {
            Log.e("123", "login: "+e.getMessage());
//            e.printStackTrace();
            return false;
        }
    }
}
